
// 配置服务器的地址 baseURL
// const baseURL = 'http://121.89.205.189:3000/api'
const baseURL = 'http://127.0.0.1:3000/api'

export default {
  get(url, params){
      wx.showLoading({
        title: '加载中...',
      })
      return new Promise((resolve, reject)=>{
        wx.request({
          url: baseURL + url,
          data: params || {},
          header: {},
          method: 'GET',
          success: res => resolve(res.data),
          fail: err => reject(err),
          complete: ()=>{
            // 关闭加载中的视图
            wx.hideLoading()
          }
        })
      })
  },
  post(url, params){
      wx.showLoading({
        title: '加载中...',
      })
      return new Promise((resolve, reject)=>{
        wx.request({
          url: baseURL + url,
          data: params || {},
          header: {},
          method: 'POST',
          success: res => resolve(res.data),
          fail: err => reject(err),
          complete: ()=>{
            // 关闭加载中的视图
            wx.hideLoading()
          }
        })
      })
  }
}